<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />

		<link rel="stylesheet" href="../../css/vCloak.css" />
		<link href="../../css/reading/Chapternumber.css" rel="stylesheet">
	</head>

	<body>
		<div class="main">
			<header class="mui-bar mui-bar-nav">
				<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
				<div class="mui-input-row mui-checkbox mui-left quanxuan">
					<label>全选</label>
					<input type="checkbox" id="task" style="display: none;">
				</div>
				<h1 id="title" class="mui-title" style="color: #000000;">阅读计划</h1>
			</header>

			<div class="mui-content">
				<!--笔记-->
				<ul class="mui-table-view mui-table-view-chevron">
					<li class="mui-table-view-cell nocheck" v-for="list in list" :chapterId="list.chapterId">
						<div class="cc mui-input-row mui-checkbox mui-left" v-if="list.state">
							<label v-cloak>{{list.chapterName}}</label>
							<span class="nocheckbox"></span>
						</div>
						<!--<a class="mui-navigate-right" href="#">第一节</a>-->
						<div class="bb mui-input-row mui-checkbox mui-left " v-else>
							<label v-cloak>{{list.chapterName}}</label>
							<input name="checkbox" type="checkbox" class="checkbox">
						</div>
						<span class="yidawang" v-if="list.state">已打卡</span>
					</li>
				</ul>
			</div>

			<div class="footer">
				<div class="jiaru"><button type="button" class="mui-btn mui-btn-primary">打卡</button></div>
			</div>

			<div class="prompt">
				<div class="mui-backdrop">
					<!--<div class="prompt_title"><img src="../../imges/Group 592.png" /></div>-->

					<div class="prompt_text">
						<div class="prompt_noclass">恭喜你完成打卡！</div>
						<div class="prompt_new">+2<span>积分</span></div>
						<div class="prompt_newbutton prompt_a" id="note"><button type="button" class="mui-btn mui-btn-success">写读书笔记</button></div>
					</div>
					<div class="prompt_close"><img src="../../imges/Group 1010.png"></div>

					<div class="imgh">
						<button type="button" class="mui-btn mui-btn-block bliia">继续打卡</button>
					</div>
				</div>
			</div>

		</div>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/libs/zepto_1.1.3.js"></script>
		<script src="../../js/libs/vue.js"></script>
		<script src="../../js/common/common.js"></script>

		<script type="text/javascript">
			mui.init();
			window.addEventListener('refresh', function(e) { //执行刷新
				location.reload();
			});
			var chapternum = new Vue({
				el: '.main',
				data: {
					list: []
				}
			})
			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
				var obj = self.parameter;
				console.log(obj.bookuid)
				common.ajax("student/queryChapter", {
					uid: common.uid,
					token: common.token,
					bookUid: obj.bookuid /*"31600929e4d14410b742c44e69e855c0"*/
				}, function(data) {
					if(data.code == 200) {
						chapternum.list = data.data
					} else {
						mui.toast(data.message)
					}
				}, "get")

				/*document.getElementById('note').addEventListener('tap', function() {
					//打开关于页面
					mui.openWindow({
						url: 'note.html',
						id: 'note'
					});
				});*/

				$("#note").on("tap", function() {
					common.open("note.html", "note.html", obj.bookuid)
				})
				var mask = mui.createMask(callback);
				//遮罩层

				$(".footer").on("tap", function() {
					var chapters = ""
					mui('.checkbox').each(function(e, a) {
						if(this.checked) {
							chapters += $(this).parents(".mui-table-view-cell").attr("chapterId") + ','
						}
					})
					if(chapters == '') {
						mui.toast("请选择章节")
						return
					}
					common.ajax("student/clock", {
							uid: common.uid,
							token: common.token,
							bookUid: obj.bookuid,
							source: obj.source,
							planUid: obj.planuid,
							chapters: chapters.slice(0, chapters.length - 1)
						},
						function(data) {
							if(data.code == 200) {
								mask.show();
								document.getElementsByClassName("prompt")[0].style.display = "block"
								var reading = plus.webview.currentWebview('../reading/TeacherProgram.html').opener();　　　　 //触发父页面的自定义事件(refresh),从而进行刷新
								mui.fire(reading, 'Taskdetails');
								var list = plus.webview.currentWebview('../Taskdetails/Taskdetails.html').opener();　　　　 //触发父页面的自定义事件(refresh),从而进行刷新
								mui.fire(list, 'shuaxin');
							} else {
								mui.toast(data.message)
							}
							//							 location.reload() 
						})

				})

				$(".imgh").on("tap", function() {
					document.getElementsByClassName("prompt")[0].style.display = "none"
					location.reload();
				})

				$(".prompt_close").on("tap", function() {
					callback()
					mask.close()
				})
				$(".prompt_a").on("tap", function() {
					callback()
					mask.close()
				})

				function callback() {
					document.getElementsByClassName("prompt")[0].style.display = "block"
					window.addEventListener('refresh', function(e) {
						//						location.reload();
					});
				}
				document.getElementById('task').addEventListener('change', function(e) {
					var listBox = mui('.checkbox');
					if(this.checked) {
						listBox.each(function() {
							this.checked = true
						})
					} else {
						listBox.each(function() {
							this.checked = false;
						})
					}
				})
			})
		</script>
	</body>

</html>